package com.itheima.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

/*
Map的遍历
第二种方法
获取所有的键值对组合
根据键值对找键
根据键值对找值
 */
public class Demo04 {

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("宝强","马蓉");
        map.put("宋喆","马蓉");
        map.put("乃亮","小璐");
        map.put("PGone","小璐");

//Map.Entry<String, String>
        Set<Map.Entry<String,String>> entries = map.entrySet();
        entries.forEach(new Consumer<Map.Entry<String, String>>() {
            @Override
            public void accept(Map.Entry<String, String> entry) {
                System.out.print(entry.getKey());
                System.out.print("===");
                System.out.println(entry.getValue());
            }
        });

    }


}
